package com.feishi.project.broker;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: caixq
 * Date: 2018-12-25
 * Time: 下午3:25
 */
public class Test {
    public static void main(String[] args){
        List<List> list=new ArrayList();
        for (int i = 0; i < 50; i++) {
            double ds = Math.random() * 180;
           list.add(Arrays.asList(ds,5*Math.pow(ds,4)+8*Math.pow(ds,3)+5*Math.pow(ds,1)+11*ds));
        }
//        System.out.println(list);
        format(list);


    }

    private static void format(List list) {
        if(list.size()<2){
            return;
        }
        List l=new ArrayList();
        for (int i = 0; i < list.size() - 1; i++) {
            List<Double> ds = (List<Double>) list.get(i);
            List<Double> ds1 = (List<Double>) list.get(i+1);
            l.add(Arrays.asList(ds.get(0)-ds1.get(0),(ds.get(1)-ds1.get(1))/(ds.get(0)-ds1.get(0))));
        }
        System.out.println(l);
        format(l);

    }
}
